import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution1089 {
    public void duplicateZeros(int[] arr) {
        List<Integer> list=new ArrayList<>();
        for (int i=0;i<arr.length;i++){
            list.add(arr[i]);
            if (arr[i]==0){
                list.add(arr[i]);
            }
            arr[i]=list.get(i);
        }
    }

    public static void main(String[] args) {
        int[] arr=new int[]{1,0,2,3,0,4,5,0};
        new Solution1089().duplicateZeros(arr);
        System.out.println(Arrays.toString(arr));
    }
}
